package io.renren.modules.comment.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.comment.entity.V9CommentEntity;
import io.renren.modules.comment.service.V9CommentService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 评论管理
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-09-24 17:43:06
 */
@RestController
@RequestMapping("comment/v9comment")
public class V9CommentController {
    @Autowired
    private V9CommentService v9CommentService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("comment:v9comment:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = v9CommentService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{commentid}")
    @RequiresPermissions("comment:v9comment:info")
    public R info(@PathVariable("commentid") String commentid){
		V9CommentEntity v9Comment = v9CommentService.getById(commentid);

        return R.ok().put("v9Comment", v9Comment);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("comment:v9comment:save")
    public R save(@RequestBody V9CommentEntity v9Comment){
		v9CommentService.save(v9Comment);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("comment:v9comment:update")
    public R update(@RequestBody V9CommentEntity v9Comment){
		v9CommentService.updateById(v9Comment);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("comment:v9comment:delete")
    public R delete(@RequestBody String[] commentids){
		v9CommentService.removeByIds(Arrays.asList(commentids));

        return R.ok();
    }

}
